package edu.stu.software.family.server;

import java.net.ServerSocket;
import java.net.Socket;

import edu.stu.software.family.RabbitMQ.MQGet;

public class Server {

	/**
	 *
	 * @author huang_gong_liang
	 *
	 */
    @SuppressWarnings("resource")
	public static void main(String[] args) throws Exception {
        ServerSocket server = new ServerSocket(8899);
        //循环接受客户端消息
        System.out.println("Server begin");
        while (true){
           //获取IP地址
            Socket accept = server.accept();

            System.out.println(accept.getLocalAddress().getHostName()+"the client is connected!");
            new MQThead(accept).start();
        }
    }
}
    class MQThead extends Thread{

        private Socket socket;

        public MQThead(Socket socket) {
            this.socket = socket;
        }

        @Override
        public void run() {
            try {
                MQGet.getMsg();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

